﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Class_KetNoi
{
   public class KetNoi_TrinhDo:KetNoiCoSoDuLieu
    {
       public void them_TrinhDo(string @TenTD, string @MaNV, string @ChuyenMon, string @NgayCap, string @Truong)
       {
           SqlCommand cmd = new SqlCommand("dbo.insert_TrinhDo", cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlParameter p = new SqlParameter("@TenTD", TenTD);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@MaNV", Convert.ToInt32(MaNV));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@ChuyenMon", ChuyenMon);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@NgayCap",Convert.ToDateTime( NgayCap));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@Truong", Truong);
           cmd.Parameters.Add(p);
           cmd.ExecuteNonQuery();
       }
       public void sua_TrinhDo(string @MaTD, string @TenTD, string @MaNV, string @ChuyenMon, string @NgayCap, string @Truong)
       {
           SqlCommand cmd = new SqlCommand("dbo.update_TrinhDo", cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlParameter p = new SqlParameter("@MaTD",MaTD);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@TenTD", TenTD);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@MaNV", Convert.ToInt32(MaNV));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@ChuyenMon", ChuyenMon);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@NgayCap", Convert.ToDateTime(NgayCap));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@Truong", Truong);
           cmd.Parameters.Add(p);
           cmd.ExecuteNonQuery();
       }
       public void xoa_TrinhDo(string @MaTD)
       {
           SqlCommand cmd = new SqlCommand("dbo.delete_TrinhDo", cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlParameter p = new SqlParameter("@MaTD",MaTD);
           cmd.Parameters.Add(p);
           cmd.ExecuteNonQuery();
       }
       public DataTable Load_TrinhDo()
       {
           DataTable dt = new DataTable();
           SqlCommand cmd = new SqlCommand("Load_tbl_TrinhDo",cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           da.Fill(dt);
           return dt;
       }
    }
}
